#include <fstream>
#include <iostream>
#include <string>
using namespace std;
// g++ -o fstream fstream.cc
// 功能：复制整个文件
void Test1() {
  std::string old_name;
  std::string new_name;
  cout << "请输入你要复制的文件名:" << endl;
  cin >> old_name;
  cout << "请输入你要生成的新文件名:" << endl;
  cin >> new_name;
  ifstream ifs;
  ifs.open(old_name, ios::in);

  ifs.seekg(0, ios::end);
  int file_len = ifs.tellg();
  ifs.seekg(ios::beg);

  char file[file_len];
  ifs.read(file, file_len);
  ofstream ofs(new_name, ios::trunc | ios::out);
  ofs.write(file, file_len);
  ifs.close();
  ofs.close();
}
int main() { Test1(); }